#!/bin/sh

if [ "$1" == "" ]; then
    echo "Usage: $0 <tag>"
    exit 1
fi

TAG=$1

LIBPATH=$TAG/out/target/product/generic/system/lib
for lib in $(cd $LIBPATH; find . -name "*.so"); do
    echo $lib
    mkdir -p ../$TAG/lib/symbols/$(dirname $lib)
    # Strip symbol value/address - assume that it's unstable across compilers,
    # so will lead to spurious diffs when reproducing. There's also "size" field
    # left, but assume that's more stable and leave it in.
    nm -D $LIBPATH/$lib | cut -c10- > \
        ../$TAG/lib/symbols/$(dirname $lib)/$(basename $lib .so).sym
done
